//package com.sm.controller;
//
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.ai.chat.client.ChatClient;
//import org.springframework.ai.chat.client.advisor.vectorstore.QuestionAnswerAdvisor;
//import org.springframework.ai.vectorstore.VectorStore;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RestController;
//import reactor.core.publisher.Flux;
//
///**
// * @auther zzyy
// * @create 2025-07-09 19:37
// */
//@Slf4j
//@RestController
//public class RagController
//{
//    private final VectorStore vectorStore;
//    private final ChatClient chatClient;
//
//    public RagController(ChatClient.Builder builder, VectorStore vectorStore)
//    {
//        this.vectorStore = vectorStore;
//        this.chatClient = builder
//                .build();
//    }
//    /**
//     * http://localhost:6012/rag4aidb?msg=查询所有的用户列表
//     * http://localhost:6012/rag4aidb?msg=查询部门表信息
//     * @param msg
//     * @return
//     */
//    @GetMapping("/rag4aidb")
//    public Flux<String> rag(String msg)
//    {
//        log.info("msg: {}", msg);
//        // 向量数据库查询
//        return chatClient.prompt()
//                .user(msg)
//                .advisors(new QuestionAnswerAdvisor(vectorStore)) // 向量数据库查询
//                .stream().content();
//    }
//}
